package com.dq.commonutils.vo;

import com.dq.commonutils.pojo.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @project: guli_parent
 * @ClassName: Result
 * @author: dq
 * @creat: 2022/7/15 10:43
 */
@Data
@AllArgsConstructor
public class Result {
    private boolean success;

    private int code;

    private String msg;

    private Object data;


    private Result() {
    }
    public static Result success(Object data) {
        return new Result(true, ResultCode.SUCCESSS.getCode(), ResultCode.SUCCESSS.getMsg(), data);
    }
    public static Result data(String name,Object data) {
        Map<String, Object> map = new HashMap<>();
        map.put(name,data);
        return new Result(true, ResultCode.SUCCESSS.getCode(), ResultCode.SUCCESSS.getMsg(), map);
    }
    public static Result error(int code, String msg) {
        return new Result(false, code, msg, null);
    }
}